package com.example.demo.Service;


import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.example.demo.entity.Book;
import com.example.demo.mapper.BookMapper;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class BookService {
    @Resource
    private BookMapper bookMapper;

    public Book getByIsbn(String isbn) {
        LambdaQueryWrapper<Book> wrapper = Wrappers.lambdaQuery();
        wrapper.eq(Book::getIsbn, isbn);
        return bookMapper.selectOne(wrapper);
    }

    public boolean updateById(Book book) {
        return bookMapper.updateById(book) > 0;
    }

    public List<Book> getAllBooks(){
        return bookMapper.getAllBooks();
    }
    public List<Book> getBorrowRank(){
       return bookMapper.getBorrowRank();
    }
    // 获取指定 book_isbn 下的所有副本
    public List<Book> getBooksByBookIsbn(String bookIsbn) {
        return bookMapper.getBooksByBookIsbn(bookIsbn);
    }
}
